<?php if(defined(TPL_PATH)) {die('invalid');} ?>
<?php include("header.php"); ?>
<body>
    <form method="post" action="">
        <div class="panel admin-panel">
            <div class="panel-head"><strong class="icon-reorder"> 教师管理</strong></div>
            <div class="padding border-bottom">
                <ul class="search">
                    <li>
                        <button type="button"  class="button border-green" id="checkall"><span class="icon-check"></span> 全选</button>
                        <button type="button" attr-url="./index.php?act=teacher_del" class="button border-red" id="delall"><span class="icon-trash-o"></span> 批量删除</button>
                        <a class="button border-main" href="./index.php?act=teacher_edit"><span class="icon-trash-o"></span> 新增</a>
                    </li>
                </ul>
            </div>
            <table class="table table-hover text-center">
                <tr>
                    <th width="120">ID</th>
                    <th>姓名</th>
                    <th>电话</th>
                    <th>教龄</th>
                    <th>操作</th>
                </tr>
                <?php
                foreach ($list as $key => $v)
                {
                    ?>
                    <tr>
                        <td>
                            <input type="checkbox" name="id[]" value="<?php echo safe($v, 'id');?>" />
                            <?php echo safe($v, "id");?>
                        </td>
                        <td><?php echo safe($v, "teacher_name");?></td>
                        <td><?php echo safe($v, "teacher_tel");?></td>
                        <td><?php echo safe($v, "teach_age");?></td>
                        <td>
                            <div class="button-group">
                                <a class="button border-main" href="./index.php?act=teacher_edit&id=<?php echo $v['id'];?>">
                                    <span class="icon-edit"></span>修改
                                </a>
                                <a class="button border-red" href="javascript:void(0)" onclick="return del(<?php echo $v['id'];?>)">
                                    <span class="icon-trash-o"></span> 删除
                                </a>
                            </div>
                        </td>
                    </tr>
                    <?php
                }
                ?>
                <tr>
                    <td colspan="8">
                        <?php echo $page;?>
                    </td>
                </tr>
            </table>
        </div>
    </form>
<script type="text/javascript">
    function del(id)
    {
        let p = "<?php echo safe($_GET, 'p', 0);?>";
        var url = "index.php?act=teacher_del&id=" + id;
        if(confirm("您确定要删除吗?"))
        {
            if (p > 0)
            {
                url += "&p=" + p;
            }
            window.location.href=url;
        }
    }
</script>
</body>
</html>